package com.StarStudio.Mapper;

import com.StarStudio.Domain.Device;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeviceMapper {

    @Select("select * from device")
    public List<Device> getAll();

    @Select("select * from device where device_id = #{deviceId}")
    public Device getById(int deviceId);

    @Insert("insert into device values (null,#{deviceName}, #{deviceType},#{deviceLocation}, #{deviceStatus}, #{deviceData}, #{deviceUpdatetime})")
    @Options(useGeneratedKeys = true)
    public void add(Device device);

    @Update("update device set device_name=#{deviceName},device_type=#{deviceType},device_location = #{deviceLocation},device_status=#{deviceStatus},device_data=#{deviceData},device_updatetime=#{deviceUpdatetime}  where device_id = #{deviceId}")
    public void update(Device device);

    @Delete("delete from device where device_id = #{deviceId}")
    public void delete(int deviceId);

    @Insert("insert into zone_device values(#{zone_id},#{device_id})")
    public void addToZone_Device(@Param("zoneId") int zoneId, @Param("deviceId") int deviceId);
}
